using System;
using System.Collections.Generic;
using System.Text;

namespace SistPaquetesClient.core
{
    /// <summary>
    /// Herramientas de validacion valores
    /// </summary>
    public class ValidationUtils
    {
        public static bool validateRequired(string text)
        {
            return text != null && text.Trim().Length > 0;
        }

        public static bool validateInt(string text)
        {
            if (text == null) return false;
            try
            {
                int.Parse(text);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool validatePossitiveInt(string text)
        {
            if (text == null) return false;
            try
            {
                int value = int.Parse(text);
                return value >= 0;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool validateFloat(string text)
        {
            if (text == null) return false;
            try
            {
                float.Parse(text);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool validatePossitiveFloat(string text)
        {
            if (text == null) return false;
            try
            {
                float value = float.Parse(text);
                return value >= 0;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool validateSpaces(string text)
        {
            return !text.Contains(" ");
        }


    }
}
